package com.schtkc.fishingmaster.utils;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * MTool
 *
 * @Author: ydz
 * @CreateTime: 2022-06-05  15:33
 */
public class Helper {

    public static ApiInfo apiInfo(String key) {
        Contact contact = new Contact("Souja", "https://baike.baidu.com/item/soulja/10406427?fr=aladdin", "782579195@qq.com");
        return new ApiInfo("钓鱼大师" + key + " Api文档",
                "用户端",
                "v1.0",
                "http://dyds.schtkc.com",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

    public static boolean isEmpty(String s) {
        return s == null || s.trim().length() == 0;
    }

    public static boolean isIdInvalid(Integer id) {
        return id == null || id <= 0;
    }

    //验证手机号
    private static final String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";

    /**
     * 验证手机号是否合法
     *
     * @param phone 手机号
     * @return boolean true合法 false不合法
     * @Author HB
     * @Date 2021/2/26 11:05
     **/
    public static boolean isPhoneInvalid(String phone) {
        if (!phone.matches(REGEX_MOBILE)) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isVCodeInvalid(String verifyCode){
        return verifyCode == null || verifyCode.trim().length() != 6;
    }

    public static String getCurrentDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        return formatter.format(new Date());
    }

    public static boolean isNoneBlank(String s) {
        return s == null || s.isEmpty() || s.equals("null") || s.equals("undefiend");
    }

}
